package com.meta.platform.login.plus.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Data;

/**
 * 验证码配置
 *
 * @author pengjianfeng
 * @version 1.0
 * @date 2021/1/11 3:57 下午
 */
@Data
@Component
@ConfigurationProperties(prefix = LoginPlusProperties.LOGIN_PLUS_PREFIX)
public class LoginPlusProperties {
    
    public static final String LOGIN_PLUS_PREFIX = "login.plus";
    
    public static final String DEFAULT_PLACEHOLDER_NAME = "code";
    
    public static final String DEFAULT_EXPIRATION_PLACEHOLDER_NAME = "expired";
    
    /**
     * 验证码配置
     */
    private VCode vCode = new VCode();
    
    /**
     * 微信小程序配置
     */
    private WeChatMin weChatMin = new WeChatMin();
    
    /**
     * 验证码 properties.
     */
    @Data
    public static class VCode {
        
        /**
         * 验证码过期时间（单位：分钟）
         */
        private int expiredTime = 5;
        
        /**
         * 验证码长度，最小4位，最大8位
         */
        private int length = 6;
        
        /**
         * 是否激活验证码发送能力，开发测试环境可设置为false，生成环境设置true
         */
        private boolean active = true;
        
        /**
         * 验证码变量名称
         */
        private String codePlaceholderName = DEFAULT_PLACEHOLDER_NAME;
        
        /**
         * 过期时间变量名称
         */
        private String expiredPlaceholderName = DEFAULT_EXPIRATION_PLACEHOLDER_NAME;
        
        /**
         * 短信渠道，模板key
         */
        private String smsKey = "send_sms_code";
        
        /**
         * 邮件渠道，模板key
         */
        private String mailKey;
    }
    
    /**
     * 微信小程序 properties.
     */
    @Data
    public static class WeChatMin {
        
        /**
         * appID
         */
        private String appId;
        
        /**
         * appSecret
         */
        private String appSecret;
    }
}
